import { createApp } from 'vue'
import App from './App.vue'
import router from '@/router'
import { createPinia } from 'pinia'
import persist from 'pinia-plugin-persistedstate'
import Storage from '@/assets/js/storage'
import request from '@/assets/js/request'
import Empty from '@/components/Empty.vue'
import Validator from './assets/js/validator'
// import { initMQTT } from './assets/js/mqttService'
import useStore from '@/store'
import fets from '@/assets/js/feRequest'
import Utils from '@/assets/js/utils'

// 引入loading组件
import eLoading from '@/assets/js/loading'

import 'vant/lib/index.css'
import { Dialog, Radio, RadioGroup, Icon } from 'vant'

// 引入element-plus
import * as ElIcons from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'

// 引入自定义图标
import './assets/icon/iconfont.css'
import './assets/icon/iconfont.js'
import './assets/fonts/font.css'

// 引入动画组件animate
// import 'animate.css/animate.min.css'

// initMQTT()

Utils.setRemBase(1920)
const app = createApp(App)

// 全局引入语言包
import i18n, { $t } from './assets/i18n'
// 先全局挂在$i18n变量
app.config.globalProperties.$i18n = i18n
app.config.globalProperties.$t = $t
app.config.globalProperties.$validator = Validator
app.config.globalProperties.$fets = fets
app
  .use(i18n)
  .use(router)
  .use(createPinia().use(persist))
  .use(request)
  .use(Dialog)
  .use(Radio)
  .use(RadioGroup)
  .use(Icon)

for (const name in ElIcons) {
  app.component(name, ElIcons[name])
}

// 全局注册自定义loading组件l
// v-e-loading="true" 全屏等待
app.directive('eLoading', eLoading)

app.mount('#app')

// const mqttStore = useStore.useMqttStore()
// mqttStore.connectMQTT()

// const wsStore = useStore.useWsStore()
// wsStore.connectWS()
